package com.drawquest.gui.panels;

import com.drawquest.data.Quest;
import com.drawquest.network.Network;
import com.gooddies.swing.swypepanel.SwitchablePanel;
import com.gooddies.wiring.annotations.PostWiring;
import com.gooddies.wiring.annotations.Wire;
import com.gooddies.wiring.annotations.WiringComponent;

@WiringComponent(singleton = true, lazy = true)
public class MainPanel extends SwitchablePanel {

    @Wire
    private Network network;

    public MainPanel() {
        initComponents();
        setTitle("Current quest");
        imagePanel.setVerticalGap(2);
        imagePanel.setHorizontalGap(2);
    }

    @PostWiring
    private void init() {
        Quest quest = network.getCurrentQuest();
        imagePanel.setUrl(quest.getTemplate());
        setTitle(quest.getTitle());
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        footerPanel1 = new com.drawquest.gui.components.FooterPanel();
        imagePanel = new com.drawquest.gui.components.ImagePanel();
        footerPanel2 = new com.drawquest.gui.components.FooterPanel();

        setBackground(new java.awt.Color(255, 255, 255));
        setForeground(new java.awt.Color(51, 51, 51));

        imagePanel.setBackground(new java.awt.Color(255, 255, 255));
        imagePanel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(51, 51, 51), 2, true));

        javax.swing.GroupLayout imagePanelLayout = new javax.swing.GroupLayout(imagePanel);
        imagePanel.setLayout(imagePanelLayout);
        imagePanelLayout.setHorizontalGroup(
            imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 459, Short.MAX_VALUE)
        );
        imagePanelLayout.setVerticalGroup(
            imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        footerPanel2.setMaximumSize(new java.awt.Dimension(30000, 32771));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(footerPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(imagePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(imagePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(footerPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.drawquest.gui.components.FooterPanel footerPanel1;
    private com.drawquest.gui.components.FooterPanel footerPanel2;
    private com.drawquest.gui.components.ImagePanel imagePanel;
    // End of variables declaration//GEN-END:variables
}
